﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 最小化为托盘图标
{
    public partial class Form1 : Form
    {
        bool exitFlag = false;
        public Form1()
        {
            InitializeComponent();
            this.ShowInTaskbar = false;//不显示在系统任务栏
            notifyIcon.Visible = true;
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if(exitFlag == false)
                e.Cancel = true;
            this.WindowState = FormWindowState.Minimized;
        }

        private void ExitApp_Click(object sender, EventArgs e)
        {
            exitFlag = true;
            Application.Exit();
        }

        private void ShowDisplay_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Normal;
        }

        private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ShowDisplay.PerformClick();
        }
    }
}
